/* 
 * File:   main.cpp
 * Author: adamski
 *
 * Created on 23 July 2011, 08:51
 */

#include <cstdlib>
#include <fstream>
#include <iostream>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <fastcgi++/manager.hpp>
#include "Application.h"

void error_log(const char* msg) {
    using namespace std;
    using namespace boost;
    static ofstream error;

    if (!error.is_open()) {
        error.open("/tmp/errlog", ios_base::out | ios_base::app);
        error.imbue(locale(error.getloc(), new posix_time::time_facet()));
    }

    error << '[' << posix_time::second_clock::local_time() << "] " << msg << endl;
}

int main(int argc, char** argv) {

    try{
        Fastcgipp::Manager<Application> fcgi;
        fcgi.handler();
    } catch (std::exception& e){
        error_log(e.what());
    }
}

